/**
 * 
 */
package ar.com.contable.ganancias.modelVO;

import java.util.ArrayList;
import java.util.List;

import ar.com.contable.ganancias.model.CategoryStrutModel;
import ar.com.contable.ganancias.util.LabelsBag;

/**
 * Category of the items.
 * @author E420611
 *
 */
public class CategoryVO implements RowVO{
	
	private YearModelVO parent; 	
	private CategoryStrutModel categoryModel;
	
	private List<ItemVO> rows = new ArrayList<ItemVO>();

	/**
	 * Constructor.
	 * @param name
	 */
	public CategoryVO(YearModelVO parent, String nameCode) {
		this.setNameCode(nameCode);
		this.setParent(parent);
	}

	/**
	 * Constructor.
	 * @param name
	 */
	public CategoryVO(YearModelVO personFolderVO,
			CategoryStrutModel categoryStrutModel) {
		this.setParent(parent);
		this.setCategoryModel(categoryStrutModel);
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return LabelsBag.getLabelText(this.categoryModel.getNameCode());
	}


	/**
	 * @return the rows
	 */
	public List<ItemVO> getRows() {
		return rows;
	}

	/**
	 * @param rows the rows to set
	 */
	public void setRows(List<ItemVO> rows) {
		this.rows = rows;
	}

	/**
	 * @return the parent
	 */
	public YearModelVO getParent() {
		return parent;
	}

	/**
	 * @param parent the parent to set
	 */
	public void setParent(YearModelVO parent) {
		this.parent = parent;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.getName();
	}

	/**
	 * @return the nameCode
	 */
	public String getNameCode() {
		return this.categoryModel.getNameCode();
	}

	/**
	 * @param nameCode the nameCode to set
	 */
	public void setNameCode(String nameCode) {
	}

	/**
	 * @return the categoryModel
	 */
	public CategoryStrutModel getCategoryModel() {
		return categoryModel;
	}

	/**
	 * @param categoryModel the categoryModel to set
	 */
	public void setCategoryModel(CategoryStrutModel categoryModel) {
		this.categoryModel = categoryModel;
	}

	@Override
	public boolean canModify(String property) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String getValue(String property) {
		if (property.equals("detalle")){
			 return LabelsBag.getLabelText(this.getCategoryModel().getNameCode());
		}
		return "";
	}

	@Override
	public void modify(String property, Object value) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean hasChildren(Object element) {		
		return this.getRows().size() > 0;
	}

	@Override
	public Object getParent(Object element) {
		// TODO Auto-generated method stub
		return this.getParent();
	}

	@Override
	public Object[] getChildren(Object parentElement) {
		// TODO Auto-generated method stub
		return this.getRows().toArray();
	}

	@Override
	public String getColumnText(int columnIndex) {
		if (columnIndex==0){
			return this.toString();
		}
		return "";
	}



}
